package smartq.app;

import java.sql.ResultSet;

import smartq.DB.Connect;

import com.app.smart_q.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

public class SmartQ_splashActivity extends Activity {
	
	Connect con = new Connect(); 
	ResultSet rs;
	String   CustomerFirstName
			,CustomerLastName
			,Customersex
			,CustomerClass
			,CustomerPhonenumber;
	String NumberPhone ;
	Intent login;
	
	protected void onCreate(Bundle savedInstanceState) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.smartq_splash);
		
		if(Checkdata()){
			login = new Intent(SmartQ_splashActivity.this,SmartQ_Tap_Main.class);
			login.putExtra("CustomerPhonenumber", NumberPhone);
		}
		
		
		new Thread() {
			public void run() {
				try {
					sleep(2000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} finally {
					  
					if(Checkdata()){
						startActivity(login);
						finish();
						
					}else{
						Intent newActivity = new Intent(SmartQ_splashActivity.this,SmartQ_Login_Activity.class);
						startActivity(newActivity);
						finish();
					}
					
				}
			};
		}.start();
		
		
	}
	
	public boolean Checkdata(){
		final myDBClass myDb = new myDBClass(this);
		String arrData[] = myDb.SelectData("1");
		if(arrData == null){
			
//			Toast.makeText(splashActivity.this,"re",
//		 		     Toast.LENGTH_SHORT).show(); 
			return false;
		}
		NumberPhone = arrData[2];
		
		return true;
	}
	
	
}
